home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / lcppb.zip / LCPPANS.ZIP / CUBE.CPP < prev    next >
C/C++ Source or Header  |  1991-07-08  |  816b  |  36 lines

  1. // cube.cpp -- Find area of cubes and squares
  2.  
  3. #include <iostream.h>
  4.  
  5. double area(double x, double y, double z = 0);
  6.  
  7. main()
  8. {
  9.   double x, y, z;
  10.  
  11.   cout << "\nEnter three values to find the area of a cube.";
  12.   cout << "\nType 0 for the third value for a square.";
  13.   cout << "\nFor example, type 2 4 8, or 2 4 0.\n";
  14.   cin >> x >> y >> z;
  15.   if (z == 0) 
  16.     cout << "Area of square == " << area(x, y);
  17.   else
  18.     cout << "Area of cube   == " << area(x, y, z);
  19. }
  20.  
  21. double area(double x, double y, double z)
  22. {
  23.   double result = x * y;
  24.   if (z != 0)
  25.     result *= z;
  26.   return result;
  27. }
  28.  
  29.  
  30. // Copyright (c) 1990 by Tom Swan. All rights reserved
  31. // Revision 1.00    Date: 12/04/1990   Time: 05:40 pm
  32.  
  33. // Revision 1.01    Date: 07/08/1991   Time: 05:41 pm
  34. // Converted for Borland C++ 2.0
  35.  
  36.